Skip to content

Security, correctness and performance hardening (2026 Q4) - #49

Merged
michaelsanford merged 32 commits into
mainfrom
security/hardening-2026-Q4
Nov 28, 2026
Merged

michaelsanford merged 32 commits into
mainfrom
security/hardening-2026-Q4

Conversation

@michaelsanford

@michaelsanford michaelsanford commented Nov 28, 2026 •

Copy link
Copy Markdown
Owner

Security, performance and best-practice review, with one commit per finding. Each commit builds and passes tests on its own.

Process actions

  • Selection follows the PID across re-sorts, using a single comparator with a PID tie-break.
  • [d] and [g] no longer move the cursor: the table now has its own keymap.
  • Kill checks the process creation time, so it refuses a recycled PID. It also refuses wtop itself, and the confirmation closes when its process exits.
  • Kill and search results stay in the status bar for 5 s.

Collector

  • //go:uintptrescapes on the DXGI COM helper.
  • Swap now shows the pagefile instead of the commit charge.
  • Standby now reads the standby list instead of the cache working set.
  • PDH rates from the priming sample are dropped.
  • Recycled parent PIDs are ignored.
  • The process-table walk is bounded by the returned length.
  • GPU: utilisation clamped, LUID sign fixed, NVML name buffer widened.

Hardening

  • nvidia-smi runs from a fixed driver path instead of a PATH search.
  • Browsers launch at normal priority.
  • The browser profile path is confined and its reads are capped.
  • REG_EXPAND_SZ handlers are expanded; [?] is debounced.

Supply chain

  • Go 1.27.4 with golangci-lint v2.15.0. v2.13.2 cannot decode 1.27.4 export data and reports 0 issues without linting.
  • Actions bumped and SHA-pinned; module dependencies bumped.
  • govulncheck and dependency review added to CI.
  • Release jobs:
    • least-privilege permissions;
    • checkouts don't persist credentials;
    • no shared cache, plus go mod verify;
    • tags reach shell steps via $TAG only;
    • SBOM attested against the binaries;
    • attested SHA256SUMS covers every asset.
  • Attestation and cosign verification pinned to release.yml@refs/tags/<tag>.
  • winget-track mirrors only bot comments; permissions are set per job; every job has a timeout.
  • Docs: Snyk's DOM-XSS fixed, and the CSP is now script-src 'self'.

Performance

  • Process collection: 238 KB/550 allocs → 49 KB/11 allocs per tick.
  • The screen under the kill overlay is no longer rendered.

CI resolved Go from go.mod's `go 1.27.0`, so release binaries missed
every stdlib security fix through 1.27.4. golangci-lint v2.13.2 cannot
decode 1.27.4 export data and fails open; v2.15.0 lints (G304 canary).
gopsutil v4.26.10, x/sys v0.50.0, x/ansi v0.12.0; indirect go-runewidth,
x/text, purego and xo/terminfo v1.3.1 (decoder crash fixes upstream).
checkout v7.0.1, setup-go v7.1.0, attest-build-provenance v4.2.2,
cosign-installer v4.1.4 (cosign v3), upload-artifact v7.0.2,
download-artifact v8.0.2, cyclonedx-gomod v1.12.0. Verify-Release.ps1
now suggests a pinned cosign v3. winget-releaser's "# v2" comment named a
moving tag; it now records the untagged commit it actually pins.
Keys reach the table before the app's handler, and bubbles' default map
binds d (half page) and g (top). The table now has its own keymap with
no app keys in it: arrows/jk, PgUp/PgDn, Ctrl+U/D, Home/End.
The table cursor is a row index and rows re-sort every second, so [x] and
[?] could act on a process that slid under the highlight. Rows now follow
the selected PID, and one comparator with a PID tie-break replaces the
unstable sorts (descending tree sort also returned !less on ties).
The confirm overlay never expired and KillProcess opened by bare PID, so
a PID reused while it was open could terminate an unrelated process.
Snapshots now carry CreateTime; KillProcess checks it via GetProcessTimes,
the overlay closes when its process exits, and killing wtop's own PID
(which strands the terminal in raw mode) is refused.
killResultMsg was ignored, so a denied kill looked like nothing happened,
and search errors went into lastErr, which the next tick cleared. Action
outcomes now get their own status-bar message that lasts five ticks.
The overlay took its name from the rendered cell, so tree view showed
connectors and the self marker. It now reads the snapshot, and warns when
the target is part of wtop's own shell/terminal ancestry.
callVirtualMethod received &adapter/&desc as uintptr through a variadic
helper without //go:uintptrescapes, so a stack move during SyscallN could
let GetDesc1 write into stale stack memory. Added the directive.
MEMORYSTATUSEX's TotalPageFile is the commit limit (RAM + pagefiles), so
Swap duplicated Cmt and showed gigabytes on machines with no pagefile.
Swap now comes from SystemPageFileInformation, one NtQuerySystemInformation
call per tick.
Disk and GPU queries prime and are then read microseconds later on the
first Collect, so the first rate was a spike or zero, and GPU cached it
for 5 s. The first disk read now reports zero rates; the detached GPU
refresh waits out a full second after priming.
PPID is only the parent's PID at creation; after the parent exits and the
number is reused, the edge points at a younger, unrelated process. Edges
to a parent created after the child are now dropped, fixing misparented
tree rows and false self-chain marks.
Summed per-engine utilisation could exceed 100%; a negative LUID HighPart
formatted as signed never matched its PDH instance; and NVML names over
64 bytes came back empty (the V2 buffer size is 96).
Each SYSTEM_PROCESS_INFORMATION was read through an unchecked struct
overlay, so a malformed NextEntryOffset could read past the data the
kernel returned. The walk now stops at ReturnLength.
exec searched PATH with PATHEXT, so an nvidia-smi.bat earlier on PATH
would run via cmd.exe every 5 s, and PATH was scanned twice per refresh.
The exe is now resolved once from System32 or NVSMI, and WaitDelay stops
an inherited pipe holding Output past its timeout.
wtop runs below normal, and Windows hands that class to its children, so
a browser launched by [?] stayed below normal for its whole session.
wtop now lifts itself to normal for the duration of the launch only.
Local State's profile.last_used was joined onto User Data unchecked, so
"..\..\x" escaped the profile root; it must now be a single plain name.
Preferences and Local State reads are capped at 16 MiB.
A handler registered as "%ProgramFiles%\...\browser.exe" was read
unexpanded, failed the existence check, and [?] silently fell back to
DuckDuckGo instead of the user's browser engine.
Holding [?] auto-repeats the key and each repeat launched another browser
tab. Further presses are ignored until the in-flight search reports back.
QueryEscape encodes a space as "+", which an engine reads as a literal
plus when its template puts {searchTerms} in the URL path. Path-position
terms are now PathEscaped.
Nothing has scanned dependencies since Snyk was removed in #44. CI now
runs govulncheck (reachable vulns, Windows code paths) and, on PRs, the
dependency-review action.
build/sbom only upload artifacts, so contents: write drops to read;
checkouts no longer persist the token; release builds skip the shared
Go cache and run go mod verify; the tag reaches shell steps via $TAG and
anything but vX.Y.Z is rejected up front.
Snyk flagged tag_name from the GitHub API flowing into innerHTML. The tag
is now validated as vX.Y.Z and written via text nodes only; the script
moved to site.js so the CSP is script-src 'self' instead of
'unsafe-inline' (privacy.html, which has no script, gets 'none').
The documented cosign command used an unanchored identity regexp that
accepted any workflow on any ref in the repo, and gh attestation verify
checked only --repo. Both now require release.yml@refs/tags/<tag>; the
script also denies self-hosted runners.
The SBOM only had provenance of its own, which doesn't bind it to what it
describes, and the release zip had no signature or attestation at all.
Release now attests the SBOM against the .exe files and attests a
SHA256SUMS covering every asset. Docs no longer claim reproducible builds.
auto_assign and winget-track granted write scopes workflow-wide. Both now
default to permissions: {} and grant per job; auto_assign notes why its
pull_request_target trigger is safe.
Any GitHub user can comment on the winget-pkgs PR, and matching comments
were re-posted verbatim into this repo's issues. Only Bot accounts and
wingetbot are mirrored now, with @-mentions defused.
No job set timeout-minutes, so a hung step (a wedged download, a stuck
poll) held a runner for GitHub's six-hour default.
View() rendered CPU, metrics, the table and the status bar on every
frame, then discarded all of it while the confirmation was showing.
Names are kept per (PID, create time) instead of re-decoded from UTF-16
every tick, the sample maps are double-buffered, scratch slices and maps
are reused, and the CPU sort the UI immediately redoes is gone.
BenchmarkLive_CollectProcs: 238 KB/550 allocs -> 49 KB/11 allocs.
The RAM bar's "standby" segment came from \Memory\Cache Bytes, which is
in-use memory, so standby was understated and in-use derived from it was
wrong. It is now the sum of the three Standby Cache counters.
GPUSourcePowerShell and the panel's "(limited: Get-Counter)" note
described a PowerShell path that no longer exists; the source is DXGI
plus PDH. Also corrects a stale gpuCache reference in a benchmark.
@michaelsanford

Copy link
Copy Markdown
Owner Author

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@michaelsanford
michaelsanford merged commit 78f7826 into main Nov 28, 2026
8 checks passed
@michaelsanford
michaelsanford deleted the security/hardening-2026-Q4 branch November 28, 2026 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant